package com.sz.mes.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.diboot.core.util.BeanUtils;
import com.sz.mes.entity.GoodsTpye;
import com.sz.mes.mapper.GoodsTpyeMapper;
import com.sz.mes.service.GoodsTpyeService;
import com.sz.mes.service.impl.BaseCustomServiceImpl;
import com.sz.mes.vo.GoodsTpyeDetailVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
import java.io.Serializable;

/**
* 商品类型相关Service实现
* @author hem
* @version 1.0
* @date 2023-06-14
 * Copyright © szhs
*/
@Service
@Slf4j
public class GoodsTpyeServiceImpl extends BaseCustomServiceImpl<GoodsTpyeMapper, GoodsTpye> implements GoodsTpyeService {

    @Override
    public List<GoodsTpyeDetailVO> getGoodsTpyeTree(Serializable rootId) {
        LambdaQueryWrapper<GoodsTpye> queryWrapper = new LambdaQueryWrapper<GoodsTpye>();
        queryWrapper.orderByAsc(GoodsTpye::getId);
        List<GoodsTpye> goodsTpyeList = getEntityList(queryWrapper);
        List<GoodsTpyeDetailVO> goodsTpyeDetailVOList = BeanUtils.convertList(goodsTpyeList, GoodsTpyeDetailVO.class);
        return BeanUtils.buildTree(goodsTpyeDetailVOList, rootId);
    }

}
